package com.music.action.authority;

import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.music.action.BaseAction;
import com.music.authority.service.RePwdService;
import com.music.common.ParamUtil;

/**
 * 部分小功能的action相关
 * @author LFSenior
 *
 */
public class CoreAction extends BaseAction{
	
	@Autowired
	RePwdService rePwdService;
	/**
	 * 跳转到帮助页面
	 * @return
	 */
	@Action(value="help",results={@Result(name="help",location="core/help.jsp")})
	public String help(){
		return "help";
	}
	
	
	/**
	 * 跳转到设置页面
	 * @return
	 */
	@Action(value="setting",results={@Result(name="setting",location="core/setting.jsp")})
	public String setting(){
		return "setting";
	}
	
	
	/**
	 * 重置面膜
	 * @return
	 */
	@Action(value="repwd",results={@Result(name="repwd",type="json",params={"root","reParam"})})
	public String rePwd(){
		/**
		 * 获取参数
		 */
		try {
			Map<String, Object> param = ParamUtil.buildRequest(ServletActionContext.getRequest());
			rePwdService.rePwd(ParamUtil.buildUserId(ServletActionContext.getRequest()), param.get("pwd").toString());
			reParam.put("result", "T");
		} catch (Exception e) {
			reParam.put("result", "F");
		}
		return "repwd";
	}
	
}
